package com.leezt.designpattern.principles.OCP.handlers;

import com.leezt.designpattern.principles.OCP.common.NotificationEmergencyLevel;
import com.leezt.designpattern.principles.OCP.models.ApiStatInfo;
import com.leezt.designpattern.principles.OCP.services.AlertRuleManager;
import com.leezt.designpattern.principles.OCP.services.INotify;

public class ErrorAlertHandler extends AlertHandler {
    public ErrorAlertHandler(AlertRuleManager ruleMgr, INotify notification) {
        super(ruleMgr, notification);
    }

    @Override
    public void check(ApiStatInfo apiStatInfo) {
        if (apiStatInfo.getErrorCount() > ruleMgr.getMatchedRule(apiStatInfo.getApi()).getMaxErrorCount()) {
            notification.notify(NotificationEmergencyLevel.SEVERE, "...");
        }
    }
}
